local yuce = fk.CreateSkill{
  name = "ls__yuce",
}

Fk:loadTranslationTable{
  ["ls__yuce"] = "御策",
  [":ls__yuce"] = "出牌阶段结束时或当你受到伤害后，你可移去中央区内的两张牌，若花色/颜色相同，则你回复1点体力/摸一张牌。",
  ["#ls__yuce-invoke"] = "御策：你可移去中央区内的两张牌",

  ["$ls__yuce1"] = "哼！我早已了然于胸。",
  ["$ls__yuce2"] = "秉正执法，我没有软肋。",
}

local DIY = require "packages/diy_utility/diy_utility"

local spec = {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(yuce.name) and (event == fk.Damaged or player.phase == Player.Play)
    and #DIY.getCenterCards(player.room) >= 2
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToChooseCards(player, {
      target = player,
      min = 2,
      max = 2,
      skill_name = yuce.name,
      flag = {
        card_data = {
          { yuce.name, DIY.getCenterCards(room) }
        }
      },
      prompt = "#ls__yuce-invoke",
    })
    if #cards > 0 then
      DIY.removeCenterCards(player, cards)
      if Fk:getCardById(cards[1]):compareColorWith(Fk:getCardById(cards[2]), false) then
        player:drawCards(1, yuce.name)
        if Fk:getCardById(cards[1]):compareSuitWith(Fk:getCardById(cards[2]), false) and player:isWounded() then
          room:recover{ who = player, num = 1, skillName = yuce.name }
        end
      end
    end
  end,
}

yuce:addEffect(fk.EventPhaseEnd, spec)
yuce:addEffect(fk.Damaged, spec)

yuce:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

return yuce